<?php

/**
 * Contains Log class
 *
 * LICENSE: MIT
 *
 * @author Peter Pippinger
 * @category PP
 * @package PP_Log
 * @copyright Copyright (c) 2013 Peter Pippinger
 * @license http://opensource.org/licenses/MIT
 * @version 1.1.0
 * @since Class exists since release 1.0.0
 */

/**
 * Log class
 *
 * Provides handling for logfile
 *
 * @author Peter Pippinger
 * @category PP
 * @package PP_Log
 * @copyright Copyright (c) 2013 Peter Pippinger
 * @license http://opensource.org/licenses/MIT
 * @version 1.1.0
 * @since Class exists since release 1.0.0
 */
class Log
{

	/**
	 * Target of logging.
	 * (file or stdOut)
	 *
	 * @param string $info        	
	 */
	private static $_logTarget = 'file';

	/**
	 * Writes an info into the logfile.
	 *
	 * @param string $info        	
	 */
	public static function info($info)
	{
		if (self::$_logTarget == 'file')
			file_put_contents(ROOT_PATH . "/tmp/log.txt", date("Y.m.d H:i:s") . " INFO: $info\r\n", FILE_APPEND);
		elseif (self::$_logTarget == 'stdOut')
			echo date("Y.m.d H:i:s") . " INFO: $info\r\n";
	}

	/**
	 * Writes an error into the logfile.
	 *
	 * @param string $info        	
	 */
	public static function error($error)
	{
		if (self::$_logTarget == 'file')
			file_put_contents(ROOT_PATH . "/tmp/log.txt", date("Y.m.d H:i:s") . " ERROR: $error\r\n", FILE_APPEND);
		elseif (self::$_logTarget == 'stdOut')
			echo date("Y.m.d H:i:s") . " ERROR: $error\r\n";
	}
}
